﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter2.Section6
{
    public class Example03
    {
        public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            double[] tv = { 1.0 / Math.Sqrt(3.0), 
                1.0 / Math.Sqrt(3.0), 1.0 / Math.Sqrt(3.0)};
            V.Vector v = new V.Vector(tv);
            double[] at = { 1.0, 0.0, 0.0 };
            V.DirectionalDerivative df = new V.DirectionalDerivative(f,v,at);
            df.Compute();
            result += df.Result.ToString() + "\r\n";
            result += (2.0/Math.Sqrt(3.0)).ToString() + "\r\n";
        }
        private double func(double[] x)
        {
            return x[0] * x[0] * Math.Exp(-x[1]*x[2]);
        }
    }
}
// 1.1547005383792
// 1.15470053837925